package com.wxg.soapws;

import org.reficio.ws.builder.SoapBuilder;
import org.reficio.ws.builder.SoapOperation;
import org.reficio.ws.builder.core.Wsdl;
import org.reficio.ws.client.core.SoapClient;

/**
 * 
 * https://github.com/reficio/soap-ws
 * 
 * response 返回 500！
 * 
 * 
 * @author pactera
 *
 */
public class SoapWsDemo {

	public static void main(String[] args) {
		Wsdl wsdl = Wsdl.parse("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL");
		SoapBuilder builder = wsdl.binding()
				.localPart("CurrencyConvertorSoap").find();
		SoapOperation operation = builder.operation()
				.soapAction("http://www.webserviceX.NET/ConversionRate").find();
		
		String request = builder.buildInputMessage(operation);
		System.out.println("===");
		System.out.println(request);
		
		SoapClient client = SoapClient.builder()
				.endpointUri("http://www.webservicex.net/CurrencyConvertor.asmx")
				.build();
		String response = client.post(request);
		System.out.println("===");
		System.out.println(response);
	}
}
